
/* 详情表格信息 */
const tableConfig = () => {
  let header = [{
    title: '序号',
    align: 'right',
    width: 70,
    fixed: 'left',
    customRender: (text, record, index) => { return (index + 1); }
  }, {
    title: '评分指标',
    align: 'right',
    width: 170,
    fixed: 'left',
    dataIndex: 'indexName'
  }, {
    title: '被评部门',
    align: 'right',
    width: 130,
    fixed: 'left',
    dataIndex: 'indexOrgName'
  }, {
    title: '责任人',
    align: 'right',
    width: 130,
    fixed: 'left',
    dataIndex: 'scorerName'
  }, {
    title: '评分[-10,10]',
    align: 'right',
    width: 170,
    dataIndex: 'scoreValue',
    scopedSlots: { customRender: 'scoreValue' },
  }, {
    title: '意见',
    align: 'center',
    width: 240,
    dataIndex: 'scoreComments',
    scopedSlots: { customRender: 'scoreComments' },
  },

    ...getMonthData(),

  //   {
  //     title: '操作',
  //     align: 'center',
  //     width: 100,
  //     fixed: 'right',
  //     dataIndex: 'operation',
  //     scopedSlots: { customRender: 'operation' }
  // }
];

  let num = (() => {
    return header.reduce((total, obj) => {
      let n = (typeof obj.width === 'number') ? obj.width : 0;
      return total + n;
    }, 0);
  })()

  return {
    loading: false,
    scroll: { x: num, y: '500px' },
    columns: header,        // 表头信息
    dataSource: [],         // 表格数据，通过接口拿到，默认空数组
  }
}

/**
 * 返回 12 个月份数组
 * */
const getMonthData = () => {
  let arr = [];
  let myDate = new Date();
  let month = myDate.getMonth();

  for (let i = 1; i <= month; i++) {
    let monthVal = ((i < 10) ? ('0' + i) : i);
    arr.push({
      title: i + '月',
      width: 80,
      dataIndex: 'm' + monthVal,
      align: 'right'
    });
  }

  return arr;
}





export { tableConfig };
